﻿using System;
using SharpKit.JavaScript;

namespace SharpKit.Onx
{
    /// <summary>
    /// A class that collects and emits information about the user's phone calls.
    /// https://www.onx.ms/#apiPage/telephony
    /// </summary>
    [JsType(Mode = JsMode.Prototype, Export = false)]
    public class Telephony : Emitter
    {
        //No way to new this up
        private Telephony()
        { }

        #region Properties
        /// <summary>
        /// 
        /// </summary>
        [JsProperty(Name = "isIdle", NativeField = true)]
        public bool IsIdle { get { return false; } }
        #endregion

        #region Triggers (Events)
        /// <summary>
        /// trigger is received when a phone busy state is detected. Additional trigger data is available in the TelephonySignal parameter passed to the callback function.
        /// </summary>
        public event Action<TelephonySignal> Busy
        {
            [JsMethod(Name = "on", InsertArg0 = "'busy'")]
            add
            {
            }
            [JsMethod(Name = "removeListener", InsertArg0 = "'busy'")]
            remove
            {
            }
        }

        /// <summary>
        /// trigger is received when the telephony component becomes idle again. Additional trigger data is available in the TelephonySignal parameter passed to the callback function.
        /// </summary>
        public event Action<TelephonySignal> Idle
        {
            [JsMethod(Name = "on", InsertArg0 = "'idle'")]
            add
            {
            }
            [JsMethod(Name = "removeListener", InsertArg0 = "'idle'")]
            remove
            {
            }
        }

        /// <summary>
        /// trigger is received when an incoming call is detected. Additional trigger data is available in the TelephonySignal parameter passed to the callback function.
        /// </summary>
        public event Action<TelephonySignal> IncomingCall
        {
            [JsMethod(Name = "on", InsertArg0 = "'incomingCall'")]
            add
            {
            }
            [JsMethod(Name = "removeListener", InsertArg0 = "'incomingCall'")]
            remove
            {
            }
        }

        /// <summary>
        /// trigger is received when a phone off the hook state is detected. Additional trigger data is available in the TelephonySignal parameter passed to the callback function.
        /// </summary>
        public event Action<TelephonySignal> OffHook
        {
            [JsMethod(Name = "on", InsertArg0 = "'offHook'")]
            add
            {
            }
            [JsMethod(Name = "removeListener", InsertArg0 = "'offHook'")]
            remove
            {
            }
        }

        /// <summary>
        /// trigger is received when an outgoing call is detected. Additional trigger data is available in the TelephonySignal parameter passed to the callback function.
        /// </summary>
        public event Action<TelephonySignal> OutgoingCall
        {
            [JsMethod(Name = "on", InsertArg0 = "'outgoingCall'")]
            add
            {
            }
            [JsMethod(Name = "removeListener", InsertArg0 = "'outgoingCall'")]
            remove
            {
            }
        }
        #endregion
    }

    /// <summary>
    /// Telephony signal. Will be triggered when a telephony event occurs.
    /// </summary>
    [JsType(JsMode.Prototype, Export = false)]
    public class TelephonySignal : ScriptSignal
    {
        //No way to new this up
        private TelephonySignal()
        { }

        /// <summary>
        /// Retrieves the phone number on an incoming call or an outgoing call associated with this signal
        /// </summary>
        [JsProperty(Name = "phoneNumber", NativeField = true)]
        public string PhoneNumber { get { return null; } }
    }
}